﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Domain;

namespace DomainTests
{
    [TestClass]
    public class CoordinatesAssignment
    {
        [TestMethod]
        public void CanInitialiseTriangleDuringCreation()
        {
            var pointA = new Point(1.0, 2.0);
            var pointB = new Point(1.0, 0.0);
            var pointC = new Point(0.0, 1.0);
            var triangle = new Triangle(pointA, pointB, pointC);

            Assert.AreEqual(pointA, triangle.A);
            Assert.AreEqual(pointB, triangle.B);
            Assert.AreEqual(pointC, triangle.C);
        }
        [TestMethod]
        public void CheckAllVerticesAreNonCollinear()
        {
            const double x = 1.0;
            const double y = 2.0;
            var pointA = new Point(  x,   y);
            var pointB = new Point(2*x, 3*y);
            var pointC = new Point(4*x, 2*y);
            var triangle = new Triangle(pointA, pointB, pointC);

            Assert.IsFalse(triangle.IsDegenerate());
        }
        [TestMethod]
        public void CollinearVerticesGiveDegenerateTriangle() 
        {
            const double x = 1.0;
            const double y = 2.0;
            var pointA = new Point(  x, 2*y);
            var pointB = new Point(2*x, 4*y);
            var pointC = new Point(4*x, 8*y);
            var triangle = new Triangle(pointA, pointB, pointC);
            
            Assert.IsTrue(triangle.IsDegenerate());
        }
    }
}
